package logic

import (
	"context"
	"zc1/model/mysql"
	"zc1/zcrpc/internal/svc"
	"zc1/zcrpc/zcrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ZcAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewZcAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ZcAddLogic {
	return &ZcAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ZcAddLogic) ZcAdd(in *zcrpc.ZcAddRequest) (*zcrpc.ZcAddResponse, error) {
	// todo: add your logic here and delete this line
	finduser := mysql.Product{
		UserId: int(in.Userid),
		Name:   in.Name,
		Number: in.Number,
		Price:  float64(in.Price),
		Money:  float64(in.Money),
		Image:  in.Image,
	}
	mysql.DB.Debug().Create(&finduser)
	return &zcrpc.ZcAddResponse{Id: int64(finduser.ID)}, nil
}
